class MyNumber {
    volatile int number = 10;
    public void addTo1205() {
        this.number = 1205;
    }
}
public class JmmVolatile {
    public static void main(String[] args) {
        MyNumber myNumber = new MyNumber();
        new Thread(() -> {
            System.out.println("--start thread");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            myNumber.addTo1205();
            System.out.println("update value:" + myNumber.number);
        }).start();
        while (myNumber.number == 10) {}
        System.out.println("---main end--");
    }
}
